<?php
	session_start();
	require_once('database/connect.php');
        
	$errmsg_arr = array();
	$errflag = false;

	$link = mysql_connect(host, username, password);
	if(!$link) {
		die('Failed to connect to server: ' . mysql_error());
	}
	$db = mysql_select_db(database);
	if(!$db) {
		die("Unable to select database");
	}
	function clean($str) {
		$str = @trim($str);
		if(get_magic_quotes_gpc()) {
			$str = stripslashes($str);
		}
		return mysql_real_escape_string($str);
	}
	
	$username = clean($_POST['username']);
	$password = clean($_POST['password']);
	$firstname = clean($_POST['firstname']);
	$lastname = clean($_POST['lastname']);
	$password    =    md5($password);
 
if(isset($_POST['btnRegister']))
{
$query    =    "insert into users(username,passwd,firstname,lastname)values('$username','$password','$firstname','$lastname')";
$res    =    mysql_query($query);

header('location:register-success.php');
}
 
?>